window.onload=function (){

//登录成功以及出现退出登录
var name=document.getElementsByClassName('userName')[0];
var login=document.getElementsByClassName('login')[0];
var persons=document.getElementsByClassName('persons')[0];
var out=document.getElementsByClassName('out')[0];
var hideLogOut = document.getElementsByClassName('hideLogOut')[0];
var hideLogOutContent = document.getElementsByClassName('hideLogOutContent')[0];
var logOutNoBtn=document.getElementsByClassName('logOutNoBtn')[0];
var logOutYesBtn=document.getElementsByClassName('logOutYesBtn')[0];
if(localStorage.getItem('userHao')!=null || localStorage.getItem('sign')==1){
    login.style.display='none';
    persons.style.display='block';
}
console.log(localStorage.getItem('userHao'))
console.log(localStorage.getItem('password'))
out.onclick=function(){
    setTimeout(function(){
        hideLogOut.style.display = 'block';
        hideLogOutContent.style.opacity = '1';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + 400 + "px)";
    },1)
    logOutNoBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
    }
//点击确认会退出登录
    logOutYesBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
        persons.style.display='none';
        login.style.display='block';
        localStorage.removeItem('userHao');
        localStorage.removeItem('password');
        localStorage.removeItem('sign');
        window.location.href="http://localhost:8080/future/out";
    }
}

// 评论

    var apply=document.getElementsByClassName('apply')[0];
    var huiFu=document.getElementsByClassName('huiFu')[0];
    apply.onclick=function (){
        if(apply.innerHTML==="回复"){
            huiFu.style.display='block';
            apply.innerHTML="取消";
        }else if(apply.innerHTML==="取消"){
            huiFu.style.display='none';
            apply.innerHTML="回复";
        }
    }
    var replay=document.getElementsByClassName('replay')[0];
    var frameCancle=document.getElementsByClassName('frameCancle')[0];
    var frame_1=document.getElementsByClassName('frame_1')[0];
    replay.onclick=function (){
        if(frame_1.value===""){
            alert("评论不能为空");
            apply.innerHTML="回复";
            huiFu.style.display='block';
        }
        else {
            huiFu.style.display='none';
            apply.innerHTML="回复";
        }
    }
    frameCancle.onclick=function (){
        huiFu.style.display='none';
        apply.innerHTML="回复";
    }
    var look=document.getElementsByClassName('look')[0];
    var lookComment=document.getElementsByClassName('lookComment')[0];
    var down=document.getElementsByClassName('icon-down')[0];
    var jiantou=document.getElementsByClassName('icon-jiantouxiangshang')[0];
    look.onclick=function (){
        if(lookComment.style.display==='none'){
            lookComment.style.display='block';
            down.style.display='none';
            jiantou.style.display='block';
        }else if( lookComment.style.display==='block'){
            lookComment.style.display='none';
            down.style.display='block';
            jiantou.style.display='none';
        }

    }

       var hui = document.getElementsByClassName("stick")[0];
       // hui.onclick=function(){
       //     document.body.scrollTop=0;
       // }
       //滚动到一定高度会出现顶部通栏
       onscroll=function(){
           var a =document.body.scrollTop;
           // var nav = document.getElementById("sti");
           if(a>115){
               hui.style.display="block";
               console.log("aaaaaaaaa");
           }
           if(a<115){
               hui.style.display="none";
           }
       }
        var shoucang=document.getElementsByClassName('icon-shoucang')[0];
        var Btn=document.getElementsByClassName('Btn_1')[0];
        var collect=document.getElementsByClassName('collect')[0];
        Btn.onclick=function (){
            if(shoucang.className==='iconfont icon-shoucang'){
                shoucang.className='iconfont icon-shoucang2';
                collect.innerHTML='已收藏';
            }
            else {
                shoucang.className='iconfont icon-shoucang';
                collect.innerHTML='收藏';
            }
        }


        //发表评论

       var frame=document.getElementsByClassName('frame')[0];
        var send=document.getElementsByClassName('send')[0];
        var usId=document.getElementsByClassName('usId')[0];
       // console.log(usId.value);

        send.onclick=function (){
            $.ajax({
               url:'http://localhost:8080/future/music/addDiscuss',
                method:"GET",
                data:{
                   mcId:usId.value,
                    dis:frame.value,
                },
                success: function (data) {
                    console.log(data);
                    if(data.statusCode===1){
                        window.location.reload();
                    }else {
                        alter("发表评论失败！");
                    }

                },
                error: function (err) {//请求失败，执行的回调函数
                    console.log('错误');
                }
            })
        }













   }

